import uuid
from django.db import models
from django.utils import timezone


class PromptTemplate(models.Model):
    """提示词模版管理"""

    class Meta:
        db_table = "prompt_template"
        ordering = ["-create_at"]
        verbose_name = "提示词模版"
        verbose_name_plural = verbose_name

    objects = models.Manager()

    id = models.CharField(primary_key=True, default=uuid.uuid4, editable=False, max_length=255)
    name = models.CharField("模版名称", max_length=100, unique=True, help_text="模版名称")
    pre_prompt = models.TextField("提示词内容", help_text="提示词内容")
    user_input_form = models.JSONField("变量配置", default=list, help_text="JSON格式的变量配置")
    description = models.CharField("模版描述", max_length=255, null=True, blank=True, help_text="模版描述")
    create_at = models.DateTimeField("创建时间", default=timezone.now, help_text="创建时间")
    update_at = models.DateTimeField("更新时间", auto_now=True, help_text="更新时间")

    def __str__(self):
        return self.name
